@use '../../_styles/mixin.scss' as *;
@use './var.scss';

.o-upload-select {
  position: relative;
  cursor: pointer;
}
.o-upload-select-input {
  position: relative;
}
.o-upload-input {
  position: absolute;
  display: block;
  width: 0;
  height: 0;
  opacity: 0;
}
.o-upload-item {
  position: relative;
}

.o-upload-progress {
  position: absolute;
  height: var(--upload-progress-height);
  background-color: var(--upload-progress-bg-color);
  border-radius: var(--upload-progress-radius);
  overflow: hidden;
}
.o-upload-progress-bar {
  width: 0%;
  height: 100%;
  background-color: var(--upload-progress-value-bg-color);
  border-radius: var(--upload-progress-radius);
  transition: width var(--o-easing-linear) var(--o-duration-s);
}

.o-upload-row-item {
  display: flex;
  margin-top: 8px;
  padding: 0 4px;
  border-radius: var(--upload-item-radius);
  color: var(--upload-color);
  transition: background-color var(--o-easing-standard-in) var(--o-duration-m1);
  @include hover {
    background-color: var(--upload-item-bg-hover);
    .o-upload-icon-hover-in {
      opacity: 1;
    }
  }
  &.is-error {
    .o-upload-icon-hover-in {
      opacity: 1;
    }
  }
  + .o-upload-item-tip {
    padding-left: 24px;
  }
}

.o-upload-row-label {
  font-size: var(--o-font_size-tip1);
  line-height: var(--o-line_height-tip1);
  margin-right: auto;
  padding: 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}
.o-upload-icon-link {
  font-size: var(--upload-icon-size);
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.o-upload-row-icons {
  display: flex;
  margin-left: 16px;
  font-size: var(--upload-icon-size);

  > * + * {
    margin-left: 8px;
  }
}

.o-upload-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.o-upload-icon-hover-in {
  opacity: 0;
  transition: opacity var(--o-easing-standard-in) var(--o-duration-m1);
}

.o-upload-icon-loading {
  margin-left: 8px;
}
.o-upload-select-extra {
  font-size: var(--o-font_size-tip2);
  line-height: var(--o-line_height-tip2);
  color: var(--o-color-info4);
  margin-top: 8px;
}
.o-upload-item-tip {
  font-size: var(--o-font_size-tip2);
  line-height: var(--o-line_height-tip2);
  color: var(--o-color-info1);
  display: flex;
  margin-top: 4px;
  &.is-error {
    color: var(--upload-color-error);
  }
}

.o-upload-row-progress {
  left: 4px;
  right: 4px;
  bottom: 0;
}

// 图片上传
.o-upload-card-add {
  border: var(--upload-card-bd);
  background-color: var(--upload-card-bg-color);
  width: var(--upload-card-width);
  height: var(--upload-card-height);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--upload-card-radius);
  text-align: center;
  color: var(--upload-color);
  cursor: pointer;
  font-size: var(--o-font_size-tip1);
  line-height: var(--o-line_height-text1);
  @include hover {
    border: var(--upload-card-bd-hover);
    background-color: var(--upload-card-bg-color-hover);
  }
  &.is-disabled {
    cursor: not-allowed;
    color: var(--upload-color-disabled);
    border: var(--upload-card-bd-disabled);
    background-color: var(--upload-card-bg-color-disabled);
  }
}
.o-upload-card-add-icon {
  font-size: var(--upload-icon-size-l);
  vertical-align: top;
  + .o-upload-card-label {
    margin-top: 8px;
  }
}

.o-upload-card-list {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: calc(var(--upload-card-gap) * -1);
  position: relative;
}
.o-upload-card-progress {
  left: 8px;
  right: 8px;
  bottom: 4px;
}
.o-upload-item {
  margin-right: var(--upload-card-gap);
  margin-bottom: var(--upload-card-gap);
}
.o-upload-card-item {
  &.is-error {
    .o-upload-card-file {
      border: var(--upload-card-bd-error);
    }
  }
}
.o-upload-card-item-wrap {
  position: relative;
  border-radius: var(--upload-card-radius);
}
.o-upload-card-file {
  border: var(--upload-card-bd);
  background-color: var(--upload-card-bg-color);
  width: var(--upload-card-width);
  height: var(--upload-card-height);
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border-radius: inherit;
}

.o-upload-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: var(--upload-card-img-fit);
  border-radius: inherit;
}
.o-upload-icon-file {
  font-size: var(--upload-icon-size-xl);
}
.o-upload-card-icons {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  background-color: var(--upload-card-mask);
  border-radius: inherit;

  opacity: 0;
  transition: opacity var(--o-easing-standard-in) var(--o-duration-m1);
  @include hover {
    opacity: 1;
  }
  &.is-show {
    opacity: 1;
  }

  > * + * {
    margin-left: 12px;
  }

  > .o-upload-icon-btn {
    cursor: pointer;
    color: var(--o-color-info1-inverse);
    font-size: var(--upload-icon-size-l);
    @include hover {
      &:hover {
        color: var(--upload-card-icon-color-hover);
      }
    }
    &:active {
      color: var(--upload-card-icon-color-active);
    }
  }
}

// 拖拽上传
.o-upload-drag {
  padding: var(--upload-drag-padding);
  font-size: var(--o-font_size-tip1);
  line-height: var(--o-line_height-text1);
  color: var(--upload-drag-color);
  background-color: var(--upload-drag-bg-color);
  border: var(--upload-drag-bd);
  text-align: center;
  width: var(--upload-drag-width);
  border-radius: var(--upload-drag-radius);
  text-align: center;
  transition: all var(--o-easing-standard) var(--o-duration-m2);
  @include hover {
    border: var(--upload-drag-bd-hover);
    background-color: var(--upload-drag-bg-color-hover);
  }
  &:active {
    border: var(--upload-drag-bd-active);
    background-color: var(--upload-drag-bg-color-active);
  }
}
.o-upload-drag-dragging {
  &,
  &:active {
    border: var(--upload-drag-bd-dragging);
    background-color: var(--upload-drag-bg-color-dragging);
  }
  @include hover {
    border: var(--upload-drag-bd-dragging);
    background-color: var(--upload-drag-bg-color-dragging);
  }
}
.o-upload-drag-disabled {
  @include me-hover {
    cursor: not-allowed;
    color: var(--upload-drag-color-disabled);
    border: var(--upload-drag-bd-disabled);
    background-color: var(--upload-drag-bg-color-disabled);
  }
}

.o-upload-drag-icon {
  font-size: var(--upload-icon-size-l);
  vertical-align: top;
  + .o-upload-drag-label {
    margin-top: 12px;
  }
}

.o-upload-list-picture-card {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: calc(var(--upload-card-gap) * -1);
  position: relative;
  .o-upload-item-tip {
    padding-left: 0;
    margin-bottom: 8px;
  }
  .o-upload-item-progress {
    left: 0;
    right: 0;
  }
}

.o-upload-item-picture-card {
  border: var(--upload-card-border);
  width: var(--upload-card-width);
  height: var(--upload-card-height);
  flex-shrink: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--upload-card-radius);
  position: relative;

  margin-right: var(--upload-card-gap);
  margin-bottom: var(--upload-card-gap);
  margin-top: 0;
  &.is-error {
    border: var(--upload-card-border-error);
  }
}
.o-upload-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: var(--upload-card-img-fit);
  border-radius: inherit;
}
.o-upload-icon-file {
  font-size: var(--upload-icon-size-xl);
}
.o-upload-card-icons {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--o-color-info1-inverse);
  font-size: var(--upload-icon-size-l);

  background-color: var(--upload-card-mask);

  opacity: 0;
  transition: opacity var(--o-easing-standard-in) var(--o-duration-m1);

  &:hover,
  &.is-show {
    opacity: 1;
  }

  > * + * {
    margin-left: 12px;
  }

  > .o-upload-icon-btn {
    cursor: pointer;
    &:hover {
      color: var(--upload-card-icon-color-hover);
    }
    &:active {
      color: var(--upload-card-icon-color-active);
    }
  }
}
